package de.iritgo.skillfull.component.visitor;

import java.awt.Point;

import de.iritgo.skillfull.component.motion.RotationComponent;
import de.iritgo.skillfull.component.visual.AnimationRenderComponent;
import de.iritgo.skillfull.component.visual.ImageRenderComponent;
import de.iritgo.skillfull.component.visual.SpriteSheetRenderComponent;
import de.iritgo.skillfull.entity.Entity;

/**
 * Set a rotation on the components
 * 
 * @author held
 *
 */
public class RotationVisitor extends BaseVisitor
{
	private float rotation;
	
	public RotationVisitor (float rotation)
	{
		this.rotation= rotation;
	}

	@Override
	public void visit(Entity entity) 
	{
		super.visit(entity);
		entity.setRotation (rotation);
	}
	
	public void visit(RotationComponent rotateComponent) 
	{
		Point pos = entity.getPosition();
		rotateComponent.setX(pos.x);
		rotateComponent.setY(pos.y);
		rotateComponent.setRotation (rotation);
	}
	public void visit (ImageRenderComponent renderComponent)
	{
		renderComponent.setRotation (rotation);
	}

	public void visit (AnimationRenderComponent animationRenderComponent)
	{
		animationRenderComponent.setRotation (rotation);
	}

	public void visit(SpriteSheetRenderComponent spriteSheetRenderComponent) 
	{ 
		spriteSheetRenderComponent.setRotation (rotation);
	}
}
